<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich">

<ui:composition template="/WEB-INF/templates/templateMenu.xhtml">
	<ui:define name="body">
		<a4j:form>
			<rich:toolBar>
				<h:outputText styleClass="texto_negrito" value="Cadastro e Manutenção de Transações - Consulta" />
			</rich:toolBar>			
			<h:panelGrid columns="3" styleClass="texto_negrito">
				<h:outputLabel value="Conta:" />
				<h:outputText value="#{contaBean.contaSelecionada.nome}" />
				<rich:spacer />
				<h:outputLabel value="Mês"/>
				<h:selectOneMenu value="#{contaBean.mes}" id="selectMes">
					<f:selectItem itemLabel="-- Selecione um mês --"/>
					<f:selectItems value="#{contaBean.meses}"/>
				</h:selectOneMenu>
				<rich:message for="selectMes"/>
				<a4j:commandButton value="Filtrar" action="#{contaBean.listarTransacoesMes}" reRender="tblConsultaTransacoes"> </a4j:commandButton>
			</h:panelGrid>
			<h:panelGrid columns="1" width="100%">
				<rich:dataTable style="text-align:center;" value="#{contaBean.contaSelecionada.listaTransacoes}" var="transacao" width="100%" id="tblConsultaTransacoes" binding="#{transacaoBean.tblConsultaTransacoes}" rowClasses="tb_cor2,tb_cor1" >
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Título" />
						</f:facet>
						<h:outputText value="#{transacao.titulo}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Valor"/>
						</f:facet>
						<h:outputText value="#{transacao.valor}">
							<f:convertNumber currencySymbol="R$" locale="pt_BR" type="currency"/>
						</h:outputText>
					</rich:column>
					<rich:column sortBy="#{transacao.data}">
						<f:facet name="header">
							<h:outputText value="Data" />
						</f:facet>
						<h:outputText value="#{transacao.data}">
							<f:convertDateTime locale="pt_BR" pattern="dd/MM/yyyy"/>
						</h:outputText>
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Descrição" />
						</f:facet>
						<h:outputText value="#{transacao.descricao}" />
					</rich:column>
					<rich:column sortBy="#{transacao.tipo}">
						<f:facet name="header" >
							<h:outputText value="Tipo" />
						</f:facet>
						<h:outputText value="#{transacao.tipo}" />
					</rich:column>	
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Ações" />
						</f:facet>
						<h:panelGrid columns="3" cellpadding="5">
							<a4j:commandLink ajaxSingle="true" action="#{transacaoBean.delete}"  reRender="tblConsultaTransacoes">
								<h:graphicImage border="0" value="/imagens/delete.png" />
								<h:outputText value="Excluir" />
							</a4j:commandLink>

							<a4j:commandLink ajaxSingle="true"	action="#{transacaoBean.edicaoTransacao}">
								<h:graphicImage border="0" value="/imagens/edit.png" />
								<h:outputText value="Alterar" />
							</a4j:commandLink>							
						</h:panelGrid>
					</rich:column>				
				</rich:dataTable>
			</h:panelGrid>		
			<h:panelGrid rendered="#{empty contaBean.contaSelecionada.listaTransacoes or contaBean.contaSelecionada.listaTransacoes == null}">
				<h:outputText value="Ainda não existem transações para essa conta." />
			</h:panelGrid>
			</a4j:form>
			</ui:define>

	</ui:composition>

</html>